package model

import (
	"math/big"
	"time"
)


const (
	// OrderType
	WaitBegin = "0" //等待前序交易
	WaitExec  = "1" //待执行
	Execing   = "2" //执行中（有hash）
	Successed = "3" //完成
	Failed    = "4" //执行失败
	// ServiceType
	BotSign            = "BotSign"            // BOT签名
	ExecCrossChainTask = "ExecCrossChainTask" // 执行Evn任务
	ExportAccountPrivate = "ExportAccountPrivate" //导出账户私钥
	CheckBalance       = "CheckBalance"       //检测余额
	// CallbackResult
	CallBackSuccess = "success"
	CallBackFailed  = "fail"
	// BotType
	Sign = "sign"
	Exec = "exec"
	// RedisKey
	NeedBalanceAssetsChain = "NeedBalanceAssetsChain"
	RDPrefixEvmOrder       = "EvmOrderInfo_"
	RDPrefixEvmAPIOrder    = "EvmAPIOrderInfo_"
	RDPrefixCosmosOrder    = "CosmosOrderInfo_"
	// DexType
	Encentive = "Encentive"
	Pancake   = "Pancake"
	// ExecType
	Bank   = "bank"
	Store   = "store"
	Instantiate   = "instantiate"
	Execute   = "execute"

	AddressZero   = "0x0000000000000000000000000000000000000000"
	CosmosChainID = 88886666

	FlagAmount  = "amount"
	UserInfoUrl = "/cosmos/auth/v1beta1/accounts/"
)

var (
	Yellow = string([]byte{27, 91, 51, 51, 109})
	Red    = string([]byte{27, 91, 51, 49, 109})
	Reset  = string([]byte{27, 91, 48, 109})
)

type Account struct {
	Addr     string `json:"addr"`
	PriKey   string `json:"prikey"`
	Type     string `json:"type"`
	TradeNum int    `json:"tradenum"`
}

type OperatorTokenAuthC struct {
	MaxDailyAmount *big.Int
	MaxAmountPerTx *big.Int
}

type WokerRecord struct {
	UseRecord         UseRecordC
	OperatorTokenAuth OperatorTokenAuthC
}

type UseRecordC struct {
	LastTime        uint32
	AmountPaid      *big.Int
	DailyAmountUsed *big.Int
}

type HybridgeOrder struct {
	ID              int32     `json:"id"`
	Node            string    `json:"node"`          // 资金节点
	AmountIn        string    `json:"amount_in"`     // 收到金额
	AmountOut       string    `json:"amount_out"`    // 支出金额
	TokenIn         string    `json:"token_in"`      // 收到币种. 零地址表示平台币
	TokenOut        string    `json:"token_out"`     // 支出币种. 零地址表示平台币
	Receiver        string    `json:"receiver"`      // 收款地址
	PayorderID      string    `json:"payorder_id"`   // 订单ID
	SrcHash         string    `json:"src_hash"`      // 源链交易Hash
	DstHash         string    `json:"dst_hash"`      // 目标链交易Hash
	WorkflowHash    string    `json:"workflow_hash"` /*	定案状态: 0、等待前序交易；1、待执行；2、执行中（有hash）；3、执行成功；4、执行失败；*/
	State           string    `json:"state"`
	Type            string    `json:"type"`               // 订单类型：0、EVM订单；1、cosmos订单；
	Network         string    `json:"network"`            // 源链ID-目标链ID
	InsertTime      time.Time `json:"insert_time"`        // 创建时间
	LockTimeStamp   string    `json:"lock_time_stamp"`    // 任务锁定时间
	SwapDstChainGas string    `json:"swap_dst_chain_gas"` // 兑换目标链GAS
}

type ApiResult struct {
	Data HybridgeOrder `json:"data"`
	Msg  string        `json:"msg"`
	Ret  int           `json:"ret"`
}

type ResponseStruct struct {
	Account AccountStruct
}

type AccountStruct struct {
	Type          string
	Address       string
	Pubkey        PubKeyStruct
	AccountNumber string
	Sequence      string
}

type PubKeyStruct struct {
	Type string
	Key  string
}
